<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            position: relative;
            width: 200px;
            height: 200px;
            margin: 200px;
            padding: 10px;
            border: 5px solid black;
            background-color: #f00;
        }
        div p{
            width: 100px;
            height: 100px;
            margin-left: 50px;
            background-color: aquamarine;
        } 
    </style>
</head>
<body>
    <div>
        <p></p>
    </div>
    <script>
        var div=document.querySelector('div');
        // var x=div.offsetLeft;
        // var y=div.offsetTop;
        // var w=div.offsetWidth;
        // var h=div.offsetHeight;
        // alert('x:'+x+'y:'+y+'w:'+w+'h:'+h);
        var p=document.querySelector('div p');
        var x=p.offsetLeft;
        var y=p.offsetTop;
        alert('x:'+x+'y:'+y);
    </script>
</body>
</html>